#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import "User.h"
#import "Tweet.h"


#define kDMCodeAskCard @"ASK_CARD"

#define kDMResultCardAccept @"ASK_CARD_AGREE"
#define kDMResultCardReject @"ASK_CARD_REJECT"

@interface DirectMessage : Tweet
{
	User*           recipient;
    sqlite_int64    senderId;
    sqlite_int64    recipientId;
    NSString*       senderScreenName;
    NSString*       recipientScreenName;
    
    NSString*   appendCode;
    NSString*   appendParams;
    NSString*   appendResult;
}

@property (getter=tweetId, setter=setTweetId:) sqlite_int64     messageId;
@property (retain, getter=user, setter=setUser:) User*          sender;

@property (nonatomic, retain) User*         recipient;
@property (nonatomic, assign) sqlite_int64  senderId;
@property (nonatomic, assign) sqlite_int64  recipientId;
@property (nonatomic, retain) NSString*     senderScreenName;
@property (nonatomic, retain) NSString*     recipientScreenName;

@property (nonatomic, retain) NSString* appendCode;
@property (nonatomic, retain) NSString* appendParams;
@property (nonatomic, retain) NSString* appendResult;

+ (int)restore:(sqlite_int64)userId messageArray:(NSMutableArray*)array all:(BOOL)all;
+ (DirectMessage*)messageWithJsonDictionary:(NSDictionary*)dic;

+ (BOOL)isExists:(sqlite_int64)messageId;;
+ (sqlite_int64)lastSentMessageId;
+ (DirectMessage*) lastSendMessage;
+ (int)countMessages:(int)userId;

- (DirectMessage*)initWithJsonDictionary:(NSDictionary*)dic;

- (void)insertDB;
- (void)deleteFromDB;

- (int)getConversation:(NSMutableArray*)messages;


- (id)copyWithZone:(NSZone *)zone;


- (NSString*) askId;

@end
